package com.demo.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.demo.dao.Result;
import com.demo.pojo.system.OperLog;
import com.demo.service.system.OperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/operLog")
public class OperLogController {
    @Autowired
    private OperLogService operLogService;

    @PostMapping
    public Result addOperLog(@RequestBody OperLog operLog) {
        operLogService.save(operLog);
        return Result.success();
    }
    @GetMapping
    public Result<Page<OperLog>> getOperLogList(int pageNum, int pageSize,
                                                @RequestParam(required = false,defaultValue = "") String title,
                                                @RequestParam(required = false,defaultValue = "") String operName) {
        Page<OperLog> page = operLogService.lambdaQuery()
                .like(OperLog::getTitle, title)
                .like(OperLog::getOperName, operName)
                .page(Page.of(pageNum, pageSize));
        return Result.success(page);
    }
}
